home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Development Kits / Mac OS / Installer SDK 1.2.4 / Upgrader 1.2.3 & Engines / Upgrader 1.2.3 / Plug-in Examples / Common Files / UpgraderPlugin.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-04  |  12.9 KB  |  352 lines  |  [TEXT/CWIE]

  1.  
  2. #ifndef __UPGRADERPLUGIN__
  3. #define __UPGRADERPLUGIN__
  4.  
  5. #ifndef REZ
  6. #include <AppleEvents.h>
  7. #include <Dialogs.h>
  8. #endif
  9.  
  10. #if defined(__MWERKS__)
  11. #include <SetUpA4.h>
  12. #include <A4Stuff.h>
  13. #endif
  14.  
  15. // General Shell error numbers that may be returned to plugins
  16. #define kCouldNotFindPluginMsgNum                    1000
  17. #define kUnknownPlugInHandlerErr                    1001                
  18. #define kNoHighLevelEventsErr                        1002                
  19. #define    kCouldNotFindResourceMsgNum                    1003
  20. #define kMemoryErrorMsgNum                            1004    
  21. #define    kCantSaveDocumentErr                        1005        // PSSaveDoc cannot save the specified DocViewer object.
  22. #define    kForceRestartWarningMsgNum                    1006
  23. #define    kAppNotFoundMsgNum                            1007
  24. #define    kDocNotFoundMsgNum                            1008
  25. #define    kAppCouldNotBeLaunchUnknownProblemMsgNum    1009
  26. #define    kAppCouldNotBeLaunchNoEnoughMemoryMsgNum    1010
  27. #define    kAppCouldNotBeLaunchFileOpenMsgNum            1011
  28. #define    kRightDiskNameWrongDiskInsertedMsgNum        1012
  29. #define    kWrongDiskInsertedMsgNum                    1013
  30. #define    kFileNotFoundOnServerMsgNum                    1014
  31. #define kCantEjectCDDiskMsgNum                        1015
  32.  
  33. // Errors Returned by PSQuitShell
  34. #define kUserContinuingAfterRestartAlertMsgNum        1030
  35.  
  36. // Plugin sequence errors 
  37. #define kUnknownPluginNameErr                        1040
  38. #define kNextPluginSameAsCurrentErr                    1041
  39.  
  40. // Global data manager errors
  41. #define kUnknownGlobalDataErr                        2000
  42. #define kGlobalDataOutOfMemErr                        2001
  43.  
  44. #define    kUnsupportedPrefsFormatErr                    2010
  45. #define    kNoPrefsErr                                    2011
  46.  
  47. // Panel manager errors                                                
  48. #define kPanelItemNotFoundInListErr                    2050                
  49. #define kCannotLoadNeededResourceErr                2051
  50. #define kNoDataAvailableForItemErr                    2052
  51. #define kInternalErr                                2053
  52. #define kNoGlobalPanelErr                            2054
  53. #define kItemTypeMismatchErr                        2055
  54. #define kCantFindTextRsrcErr                        2056
  55. #define kItemNotLocalisedErr                        2057
  56. #define    kCantChangePanelItemToSpecifiedTypeErr        2058
  57.  
  58. // Dialog IDs : these are needed by plugins to define there own private 'ners' resources
  59. #define    kStopOrContinueDLOGID                        506    // note, center parent with Stop (2) and Continue (1) buttons
  60. #define    kQuitOrContinueDLOGID                        507    // note, center parent with Continue (2) and Quit (1) buttons
  61. #define    kNoteOKDLOGID                                508    // note, alert parent with OK button
  62. #define    kRestartOrContinueDLOGID                    514    // note, center parent with Continue (2) and Restart (1)  buttons
  63. #define    kInsertDiskDLOGID                            515    // disk swap icon, center main
  64. #define    kStopOKDLOGID                                519    // stop, center parent with OK button
  65. #define    kSkipOrContinueDLOGID                        520    // caution, center parent with Skip (2) and Continue (1) buttons
  66. #define kNoteQuitDLOGID                                600 // note, center parent with Quit button
  67. #define kStopAndQuitDLOGID                            526 // stop, center main with Quit button
  68. #ifndef REZ
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72.  
  73. /* PSErrorAlert related constants */
  74. #define kEmptyString (ConstStr255Param)"\p"
  75.  
  76. // Constants that are used in PSErrorAlert to define the default button and the selected button
  77. #define kOKButtonIndex                            1
  78. // Skip or continue
  79. #define    kContinueNotSkipBtnIndex                   1
  80. #define    kSkipNotContinueBtnIndex                   2
  81. // Stop or continue
  82. #define    kContinueNotStopBtnIndex                   1
  83. #define    kStopNotContinueBtnIndex                   2
  84. // Continue or Quit
  85. #define    kQuitButtonIndex                        1
  86. #define    kContinueNotQuitBtnIndex                 2
  87. // Continue or Restart
  88. #define    kRestartButtonIndex                         1
  89. #define    kContinueNotRestartBtnIndex                 2
  90. // yes or no
  91. #define    kYesButtonIndex                            1
  92. #define    kNoButtonIndex                            2
  93.  
  94. // constants to indicate to PSErrorAlert whether to look in the
  95. // plugins resource file for the error or in the Shell resource file
  96. #define kStandardShellError    true            // Tells PSErrorAlert to look in Shell for error
  97. #define kPluginError        false            // Tells PSErrorAlert to look in Plugin res fork for error
  98.  
  99. // constants for PSQuitShell
  100. #define kDontAllowUserToContinue    false
  101. #define kAllowUserToContinue        true
  102.  
  103. //------------------------------------------------------------------------------------------------------
  104. //    G L O B A L   D A T A   D E F I N I T I O N S
  105. //------------------------------------------------------------------------------------------------------
  106. typedef    OSType            GlobalDataType;
  107. typedef    Ptr                GlobalDataPtr;
  108.  
  109. enum                                        // This is the list of global data types shared between plugin's
  110.                                             // NOTE. plugin's can store their own global data as well.
  111.     {
  112.     kTargetDiskVolRefNumDataType =    'trgt',    // The selected volume vRefNum as set by Target Selectin plugin (SInt16).
  113.     kForceRestartOnQuitDataType =     'rsrq'    // Global data identifier to singal to shell and plugins that a restart is required (Boolean).
  114.     };
  115.  
  116.  
  117. //------------------------------------------------------------------------------------------------------
  118. //    P L U G I N   D E F I N I T I O N S
  119. //------------------------------------------------------------------------------------------------------
  120. #define    kEventHandlerID            'ehID'
  121. #define    kTerminationHandlerID    'thID'
  122.  
  123. typedef OSErr             ShellErr;
  124. typedef    OSType            HandlerIDType;
  125. typedef SInt16             ResourceID;
  126.  
  127. enum    
  128. {
  129.     kUseDefaultNextModuleName = 0
  130. };
  131.  
  132. //------------------------------------------------------------------------------------------------------
  133. //    P A N E L  M A N A G E R  D E F I N I T I O N S
  134. //------------------------------------------------------------------------------------------------------
  135. typedef WindowPtr         PanelPtr;
  136.  
  137. #define    kHelpPanel      (void *)0xFFFFFFFE
  138. #define    kGlobalPanel    (void *)0xFFFFFFFF    // Pass this constant to PSShowPanel/PSHidePanel if the current
  139.                                             // global panel is unknown (eg. when the plugin does not itself display
  140.                                             // a panel).
  141.  
  142.  
  143.  
  144. //  Parameter type and constants for PSNewCustomPanel
  145. typedef    UInt8            DVFlags;
  146. enum
  147. {
  148.     // Use in inFlags parameter
  149.     kGrowWindow     = 0x02,
  150.     kIsGlobal         = 0x04,
  151.     kHasGoAwayBox    = 0x10
  152. };    
  153.  
  154.  
  155. //  Parameter type for PSSetPanelItem & PSGetPanelItem
  156. typedef unsigned long        PanelItemType;
  157.  
  158. //  Parameter type and constants for PSNewDocViewerItem
  159. typedef PanelItemType        DocViewerType;        // subset of PanelItemType
  160. enum
  161. {
  162.     // Use in inDocViewerType paramter
  163.     kStyledTextType        = 'STXT',                // 'TEXT' and 'styl' pairs
  164.     kStyledStringType    = 'SSTR',                // 'STR#', index and 'finf'
  165.     kPICTType            = 'PICT',
  166.     kDocResType            = 'DOCV',                // 'TEXT', 'styl' and 'PICT's stored in resources
  167.     kDocFileType        = 'DOCF',                // SimpleText file will optional 'styl' and 'PICT' in resource fork.
  168.     kControlType        = 'CNTL',
  169.     kIconType            = 'ICON',
  170.     kUserItemType        = 'USER'                // User panel item for drawing custom items.
  171. };
  172.  
  173.  
  174. // Parameter type and constants for PSAlert
  175. typedef short DocumentType;                        
  176. enum
  177. {
  178.     // Use in whichFileContainsDLOG parameter
  179.     kUpgraderFile = 0,
  180.     kClientDataFile,
  181.     kCurrentPluginResFile
  182. };
  183.  
  184.  
  185. // Parameter type for PSCheckEnvironment
  186. typedef    unsigned long        EnvironmentType;
  187. enum
  188. {    
  189.     kPrinterAvailableMask = 0x00000001,
  190.     kStandardFilePackageAvailableMask = 0x00000002
  191. };
  192.  
  193.  
  194. // Paramter type for PSSetupHelpWindow
  195. typedef Byte        DocLocationType;
  196. enum
  197. {
  198.     // Use in location parameter
  199.     kReadFromResourceFile = true,
  200.     kReadFromSimpleTextFile = false
  201. };
  202.  
  203.  
  204. // Parameter type and constants for PSSetPanelItemAction
  205. typedef    UInt16            PanelActionType;
  206. enum
  207. {
  208.     // Use in actionType parameter
  209.     kContinueButtonMask = 0x0001,
  210.     kGoBackButtonMask     = 0x0002,
  211.     kQuitButtonMask        = 0x0004,
  212.     kHelpButtonMask        = 0x0008,
  213.     kDefaultButtonMask    = 0x0010
  214. };
  215.  
  216.  
  217. // Result type from PSNewUserItem
  218. typedef Handle PanelUserItemHandle;
  219.  
  220.  
  221. // Constants for PSReadFontInfo
  222. enum
  223. {
  224.     // Use in location parameter
  225.     kFontInfoInClientDataFile,
  226.     kFontInfoInPluginFile,
  227.     kFontInfoInShell,
  228.     kFontInfoInAnyFile,
  229.  
  230.     // Use in inResID parameter
  231.     kUpgraderFonts    = 128,
  232.     
  233.     // Use in inFontItem parameter
  234.     kLargeTextStyle = 0,
  235.     kMediumTextStyle,
  236.     kSmallTextStyle,
  237.     kAlertTextStyle,
  238.     kReportTitleTextStyle,
  239.     kReportListTextStyle,
  240.     kReportIndentTextStyle
  241.     
  242. };
  243.  
  244.  
  245. // Constants for PSStartWaitCursor
  246. enum
  247. {        
  248.     // Use in inCursorID parameter
  249.     kWatchWaitCursor            = 128,
  250.     kCountingFingersWaitCursor    = 129
  251. };
  252.  
  253.  
  254. // Constants for HandleEventForPluginModule
  255. enum
  256. {        
  257.     // "what" field of event record set to this value so plug-in can handle menu selection ("message" file is result of MenuSelect call).
  258.     kMenuSelectionEvent            = 2087
  259. };
  260.  
  261.  
  262.  
  263.  
  264. // Constants to use with PSLaunchFile
  265. #define kLaunchAppInFront    true                // Tells PSLaunchFile to bring the launched application to the front
  266. #define kLaunchAppInBack    false                // Tells PSLaunchFile to leave the launched application in the back.
  267.  
  268.  
  269. /* Macros to customize Metrowerks code resource macros */
  270. // Call this Macro whenever control is swithched to the plugin
  271. #if defined(__MWERKS__)
  272. #define    EnterPlugin()                            \
  273.         EnterCodeResource();
  274. #endif
  275.  
  276.  
  277. // Call this Macro whenever control is from the plugin to the shell
  278. #if defined(__MWERKS__)
  279. #define ExitPlugin()                            \
  280.         ExitCodeResource()
  281. #endif
  282.     
  283. extern     QDGlobals                 *gQDPtr;
  284.  
  285.  
  286. /* ROUTINES */
  287.  
  288. // Global Data Manager calls
  289. extern ShellErr         PSSetGlobalData( GlobalDataType inGlobalDataType, GlobalDataPtr inGlobalDataPtr, Size inDataSize );
  290. extern ShellErr         PSGetGlobalData( GlobalDataType inGlobalDataType, GlobalDataPtr inGlobalDataPtr, Size inMaxDataSize, Size *outActualDataSize );
  291.  
  292. // Plugin management calls
  293. extern ShellErr         PSGoToPreviousPlugin( void );
  294. extern ShellErr         PSGoToNextPlugin( ResourceID inStrResID );
  295. extern ShellErr            PSQuitShell( Boolean canAllowUserToContinue );
  296. extern ShellErr            PSForceRestart();
  297. extern ShellErr            PSRegisterHandler( HandlerIDType inHandlerType, UniversalProcPtr inHandlerProcPtr );
  298.  
  299. // Panel management calls
  300. extern ShellErr            PSSetupNewPanel( SInt16 inPanelItemsRsrcID, PanelPtr *outPanelPanelPtr );
  301. extern ShellErr            PSNewCustomPanel( short inPanelItemsRsrcID, DVFlags inFlags, PanelPtr *outPanelPanelPtr );
  302. extern ShellErr            PSUpdatePanel( PanelPtr inPanel );
  303. extern void                PSDisposePanel( PanelPtr inThePanel );
  304. extern ShellErr         PSShowPanel(PanelPtr inPanel );
  305. extern void                PSHidePanel( PanelPtr inPanel );
  306. extern Boolean            PSGetPanelItemHit( PanelPtr inPanel, EventRecord *inPanelEvent, short *outItemHit);
  307. extern ShellErr            PSSetPanelItem(PanelPtr inPanel, short inItemNumber, PanelItemType inItemType, Handle inItemHandle, Rect *inItemRect);
  308. extern ShellErr         PSGetPanelItem(PanelPtr inPanel, short inItemNumber, PanelItemType *outItemType, Handle *outItemHandle, Rect *outItemRect);
  309. extern void                PSSetPRefCon(PanelPtr inPanel, long inRefCon);
  310. extern long                PSGetPRefCon(PanelPtr inPanel);
  311. extern ShellErr            PSSetPanelItemAction(PanelPtr panel, short itemNumber, PanelActionType actionType);
  312. extern TEHandle         PSNewStyledStringItem(Rect *inItemRect, short inSTRListRsrcID, short inStringListItem, short inFontNum, short inFontStyle, short inFontSize);
  313. extern TEHandle            PSNewStyledTextItem(Rect *inItemRect, short inTEXTRsrcID);
  314. extern PanelUserItemHandle PSNewUserItem(UserItemProcPtr inUserItem, Boolean transparent);
  315. extern Handle            PSNewDocViewerItem(PanelPtr inPanel, Rect *inItemRect, DocViewerType inDocViewerType, short inTextRsrcID, short inBasePICTRsrcID);
  316. extern ShellErr            PSActivatePanel(PanelPtr inPanel, Boolean shouldActivate);  
  317.                       
  318. // DocViewer item related calls
  319. extern ShellErr            PSHandleDocScroll(PanelPtr inPanel, Point localPt, short inDocItem);
  320. extern void                PSSaveDoc( PanelPtr inPanel, short inDocItem) ;
  321. extern ShellErr            PSPrintDoc( PanelPtr inPanel, short inDocItem );
  322.  
  323. // Standard help windows calls
  324. extern OSErr            PSSetupHelpWindow ( DocLocationType location, short resID, short basePICTResID, Str255 helpPanelTitleStr, PanelPtr *outHelpPanel );
  325. extern void                PSDisplayHelpWindow ( PanelPtr inHelpPanel );
  326. extern void                PSCloseHelpWindow ( PanelPtr helpPanel );
  327. extern Boolean            PSHandleHelpWindowEvent ( PanelPtr inHelpPanel, EventRecord *inEvent );
  328.  
  329. // Utility calls
  330. extern OSErr            PSCheckEnvironment ( EnvironmentType *theEnvironment );
  331. extern Boolean            PSReadFontInfo ( short location, short inResID, short inFontItem, short *outFontFace, short *outFontStyle, short *outFontSize );
  332. extern Boolean            PSLaunchFile(SInt16 inAppFileRefRsrcID, SInt16 inDocFileRefRsrcID, AEDescList *inOptionalOpenParams, Boolean inLaunchAppInFront, ProcessSerialNumber *outApplicationPSN);
  333. extern Boolean            PSMakeFSSpecFromFileRefID(SInt16 inFileRefID, Boolean inShowErrorAlert, FSSpec *outFoundFile );
  334. extern SInt16             PSErrorAlert( SInt16 errNum, Boolean isStandardShellErr, ConstStr255Param p0, ConstStr255Param p1, ConstStr255Param p2, ConstStr255Param p3, SInt16 inDefaultButton, SInt16 inCancelButton );
  335. extern void             PSCollect(SInt16 inResListRsrcID);
  336. extern SInt16             PSAlert(short DLOGID, DocumentType whichFileContainsDLOG, ConstStr255Param alertText, ConstStr255Param     p0, ConstStr255Param p1, ConstStr255Param p2, ConstStr255Param p3, SInt16 inDefaultButton, SInt16 inCancelButton );
  337. extern void             PSStartWaitCursor( short inCursorID, SInt16 inDelayTicks );
  338. extern void             PSStopWaitCursor( void );
  339.  
  340. /* Three required plug-in handler routines */
  341. void        InitializePluginModule        ( void* inPSTable, SInt32 inRefCon, Boolean inEnterAtBeginning );
  342. Boolean        HandleEventForPluginModule    ( EventRecord *inEvent );
  343. void         TerminatePluginModule        ( void );
  344. #define     InitializePluginModule main
  345.  
  346. void    SetupPlugin( void *shellFunctions );
  347.  
  348. #ifdef __cplusplus
  349. }
  350. #endif
  351. #endif                    //REZ                                                
  352. #endif